import Taro, { Component } from '@tarojs/taro'
import { Image, ScrollView, View } from '@tarojs/components'
import './index.scss'
import { toGoodsPage } from '@/utils/page_router'

interface IProps {
  list: any
}

/**
 * 自定义列表展示2
 */
export default class Index extends Component<IProps, {}> {
  props: any

  static options = {
    addGlobalClass: true
  }

  render() {
    const { list=[] }:any = this.props
    return (<ScrollView scrollX className='custom-two'>
      <View className='goods-list-h'>
        {list.map(goods => {
          return (<View key={goods.id} className='goods-item' onClick={() => toGoodsPage(goods)}>
            <View className='goods-img'>
              <Image src={goods.coverImg} lazyLoad/>
            </View>
            <View className='goods-foot d-f f-d-c j-c-b'>
              <View className='goods-name t-o-e-2'>{goods.name}</View>
              <View className='d-f a-i-f-e j-c-b'>
                <View className='sale-price bnn-number'>￥{goods.salePrice}</View>
                <View className='goods-btn'>立即购买</View>
              </View>
            </View>
          </View>)
        })}
      </View>
    </ScrollView>)
  }
}
